import { CloudRequest } from '../utils/cloud-request.js'
class CategoryModel extends CloudRequest {

    // /***************************    商品分类页   *****************************************/
    /**
     * 获取分类
     * @param {*} callBack 
     */
    getCateGory(callBack){
        this.request({
            url: "getCategoryMenu",
            success: res => {
              callBack(res)
            }
        })
    }
    /**
     * 根据商品类型获取商品
     * @param {*} category_type 
     * @param {*} callBack 
     */
    getCateGoryProduct(category_type,callBack){
        this.request({
            url: "getCategoryProduct",
            data:category_type,
            success: res => {
              callBack(res)
            }
        })
    }
    /**
     * 根据商品搜索获取商品
     * @param {*} Search_type 
     * @param {*} callBack 
     */
    SearchProduct(Search_type,callBack){
        this.request({
            url: "SearchProduct",
            data:Search_type,
            success: res => {
              callBack(res)
            }
        })
    }
    /**
     * 根据商品获取详情
     * @param {*} Search_type 
     * @param {*} callBack 
     */
    getDetailProduct(Search_type,callBack){
        this.request({
            url: "getDetailProduct",
            data:Search_type,
            success: res => {
              callBack(res)
            }
        })
    }

    // /***************************    购物车页   *****************************************/
    /**
     * 添加购物车
     * @param {*} addCart_type 
     * @param {*} callBack 
     */
    addCart(addCart_type,callBack){
        this.request({
            url: "addCart",
            data:addCart_type,
            success: res => {
              callBack(res)
            }
        })
    }
    /**
     * 获取购物车数据
     * @param {*} callBack 
     */
    getShopcart(callBack){
        this.request({
            url: "getShopcart",
            success: res => {
              callBack(res)
            }
        })
    }
    /**
     * 删除购物车数据
     * @param {*} remove_type 
     * @param {*} callBack 
     */
    removeShopcart(remove_type,callBack){
        this.request({
            url: "removeShopcart",
            data:remove_type,
            success: res => {
              callBack(res)
            }
        })
    }
    /**
     * 更新购物车数据 // 更新购物车数据
     * @param {*} Search_type 
     * @param {*} callBack 
     */
    updatedShopcart(updated_type,callBack){
        this.request({
            url: "updatedShopcart",
            data:updated_type,
            success: res => {
              callBack(res)
            }
        })
    }
    /**
     * 获取购物车数据
     * @param {*} callBack 
     */
    getShopcartById(category_type,callBack){
        this.request({
            url: "getShopcartById",
            data:category_type,
            success: res => {
              callBack(res)
            }
        })
    }

    /**
     * 添加购物车地址
     * @param {*} addCart_type 
     * @param {*} callBack 
     */
    addAddress(addCart_type,callBack){
        this.request({
            url: "addAddress",
            data:addCart_type,
            success: res => {
              callBack(res)
            }
        })
    }
    /**
     * 获取购物车地址
     * @param {*} callBack 
     */
    getAdress(callBack){
        this.request({
            url: "getAdress",
            success: res => {
              callBack(res)
            }
        })
    }
    /**
     * 更新购物车地址
     * @param {*} Search_type 
     * @param {*} callBack 
     */
    updatedAddress(updated_type,callBack){
        this.request({
            url: "updatedAddress",
            data:updated_type,
            success: res => {
              callBack(res)
            }
        })
    }
    /**
     * 删除购物车地址
     * @param {*} remove_type 
     * @param {*} callBack 
     */
    removeAddress(remove_type,callBack){
        this.request({
            url: "removeAddress",
            data:remove_type,
            success: res => {
              callBack(res)
            }
        })
    }
    /**
     * 生成订单
     * @param {*} addCart_type 
     * @param {*} callBack 
     */
    addOrder(addCart_type,callBack){
        this.request({
            url: "addOrder",
            data:addCart_type,
            success: res => {
              callBack(res)
            }
        })
    }
}
export { CategoryModel }